<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/20/020
 * Time: 9:35
 */
header('content-type:text/html;charset=utf-8');
//     class jobcurl{
function get($url){
            $ch = curl_init($url);
            curl_setopt($ch,CURLOPT_URL,$url);//设置url地址
            curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//返回流
            $data = curl_exec($ch);
            curl_close($ch);
            return $data;
        }
        $data = get($url);
        //职位
        //arr[1]
        $name = '/<li><a href="(.*?)" title="(.*?)" target="_blank"><img src="(.*?)" title="(.*?)" alt="(.*?)">/ies';
        preg_match_all($name,$data,$arr);
        print_r($arr);

//         public function test($url){
//             $data = $this->get($url);
//             //职位
//             //arr[1]
//             $name = '/<li><a href="(.*?)" title="(.*?)" target="_blank"><img src="(.*?)" title="(.*?)" alt="(.*?)">/ies';
//             preg_match_all($name,$data,$arr);
//             print_r($arr);
//             //公司名
//             //arr1[1]
//             //'/<span class="t2"><a.*?">(.*?)<\/span>/ies'
//             $url = '/<span class="t2"><a target="_blank" title=".*?" href="(.*?)">(.*?)<\/a><\/span>/ies';
//             $com = '/https:\/\/jobs\.51job\.com\/all.*?">(.*?)<\/a><\/span>/ies';
//             preg_match_all($com,$data,$arr1);
//             //工作地址,工资,发布时间
//             //arr2[1] arr2[2] arr2[3]
//               $area = '/<span class="t3">(.*?)<\/span>/ies';

//             $address = '/https:\/\/jobs\.51job\.com\/all.*?">.*?<\/a><\/span>.*?<span class="t3">(.*?)<\/span>.*?<span class="t4">(.*?)<\/span>.*?<span class="t5">(.*?)<\/span>/ies';
//             preg_match_all($address,$data,$arr2);
//             return array($arr[1],$arr1[1],$arr2[1],$arr2[2],$arr2[3]);

//         }
//     }
//      $c = new jobcurl();
//       $url="https://search.51job.com/list/010000,000000,0000,00,9,99,php,2,1.html";
//       $data = $c->test($url);
//       print_r($data);